import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass(PersonConfig.class)
@EnableConfigurationProperties({PersonConfigProperties.class})
public class StudyAutoConfig {

    @Autowired
    private PersonConfigProperties personConfigProperties;

    @Bean
    @ConditionalOnMissingBean
    public PersonConfigProperties PersonConfigProperties(){
        PersonConfig personConfig = new PersonConfig();
        personConfig.setId(personConfigProperties.getId());
        personConfig.setName(personConfigProperties.getName());
        return PersonConfigProperties;
    }

}